package com.zhou.entitiy;

public class ToolsResult {

    public static final ToolsResult RESULT_SUCC = new ToolsResult(true,"成功");
    public static final ToolsResult RESULT_FAIL = new ToolsResult(false,"失败");
    private boolean isSucc;
    private String msg;
    private Object[] objs;
    public ToolsResult(boolean isSucc, String msg, Object... objs){
        this.isSucc =isSucc;
        this.msg = msg;
        this.objs = objs;
    }
    public boolean isSucc() {
        return isSucc;
    }
    public boolean isFail() {
        return !isSucc;
    }

    public void setSucc(boolean isSucc) {
        this.isSucc = isSucc;
    }
    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static ToolsResult createSuccResult(String msg, Object... objs) {
        return new ToolsResult(true,msg,objs);
    }

    public static ToolsResult createFailResult(String msg, Object... objs) {
        return new ToolsResult(false,msg,objs);
    }
    @Override
    public String toString() {
        return isSucc +","+msg;
    }

    public static String getMsg(String server, String msg) {
        StringBuffer sb = new StringBuffer();
        sb.append("【").append(server.toString()).append("】").append(msg);
        return sb.toString();
    }
    public Object[] getObjs() {
        return objs;
    }
    public void setObjs(Object[] objs) {
        this.objs = objs;
    }

    public <T> T getT(int index) {
        return (T) objs[index];
    }
}
